<template>
  <div>
    <input type="text" v-model="name" ref="txtInput" />
    <button @click="handleAdd">添加</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: ""
    }
  },
  methods: {
    handleAdd() {
      let id = parseInt(Math.random()*1000);
      let val= this.$refs.txtInput.value;
      // this.$store.commit('ADD',{id,name:this.name,isedit:false})
      this.$store.commit('ADD',{id,name:val,isedit:false})
    }
  }
}
</script>

